package org.hackystat.sdsa.service.resource.ping;

import static org.junit.Assert.assertTrue;

import org.hackystat.sensorbase.client.SensorBaseClient;
import org.hackystat.sdsa.service.client.SdsaClient;
import org.hackystat.sdsa.service.test.SdsaTestHelper;
import org.junit.Test;

/**
 * Tests the Ping REST API.
 * 
 * @author Hongbing Kou
 */
public class TestPingRestApi extends SdsaTestHelper {

  /**
   * Test that GET {host}/ping returns the service name.
   * 
   * @throws Exception If problems occur.
   */
  @Test
  public void testPing() throws Exception {
    //First, just call isHost, which uses the standard ping. 
    String sdsaHost = getSdsaHostName();
    assertTrue("Checking ping", SdsaClient.isHost(sdsaHost));
    //Next, check authenticated ping. 
    String user = "TestTelPing@hackystat.org";
    SensorBaseClient.registerUser(getSensorBaseHostName(), user);
    SdsaClient client = new SdsaClient(sdsaHost, user, user);
    client.authenticate();        
  }
}
